<%= javascript_include_tag 'controllers/image_controller'%>
<div id="image_controller_space"></div>
<form id="form_selected_ids" onsubmit="return false">
<%= hidden_field_tag 'selected_ids', nil %>
</form>
<script>
    var image_controller = new ImageController;
</script>
<%= render :partial => "images" %>
<%= link_to 'Upload images', {:action => 'new', :group_id => params[:group_id]}, {:class => "upload_image_button button"} %>
<a href="javascript:void(0);" class="tag_image_button button" onclick="do_tag()">Tag Images</a>
<%= link_to_function "Slideshow", 'do_slideshow()', {:class => 'slideshow_button button', :id => 'slideshow_button'} %>
<a href="javascript:void(0);" class="tag_image_button button" onclick="do_move()">Move...</a>

<script>
image_controller.update_from_field();
function do_tag(){
    if($F('selected_ids') != ""){        
        Dialog.info({url:'/images/tag', options:{parameters: Form.serialize('form_selected_ids')}},
                {className:'alphacube',width:480})
    } else {
        flash_message('You need to choose some images first. Try clicking on them.');
    }
}
shortcut_not_input("t", function(e){
		do_tag();
	})
function do_slideshow(){
	if($F('selected_ids') != ""){
      new Ajax.Updater('image_controller_space','/images/slideshow',{parameters: Form.serialize('form_selected_ids'),
                                                                     evalScripts: true, method: 'post'})
  } else {
      document.getElementsByClassName('shortcut_image_link')[0].ondblclick();
  }
}

shortcut_not_input('s', function(e){
		do_slideshow()
	})
function do_move(){
    if($F('selected_ids') != ""){
        Dialog.info({url:'/groups/list_ajax/<%= params[:group_id]%>', options:{parameters: Form.serialize('form_selected_ids')}},
                {className:'alphacube',width:600})
    } else {
        flash_message('You need to choose some images first. Try clicking on them.');
    }
}

shortcut_not_input('m', function(e) {
        do_move();
})
</script>